package com.aaa.a1104.demo02;

import java.util.function.Consumer;

/**
 * @author 荆豪峰
 * @version 1.0
 */
public class Test02 {
    public static void main(String[] args) {
        //void accept(T t);
        //Consumer<int[]> consumer=(arr)->{Test02.sum(arr);};

        Consumer<int[]> consumer=Test02::sum;
        int[] arr={1,2,3,4};
        consumer.accept(arr);
    }

    public static void sum(int[] arr) {
        int sum = 0;
        for (int a : arr) {
            sum += a;
        }
        System.out.println("数组中元素的和:"+sum);

    }
}
